package client;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

/**
 * @file Client_Response.java
 *
 * @version 0.1
 * @author James Dibble 10009689
 */
public class Client_Response extends Thread {
    // <editor-fold defaultstate="collapsed" desc="Attributes">
    private Socket sSocket;
    private PrintWriter pwServerOutput;
    private Scanner scnrInput = new Scanner(System.in);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructors">
    public Client_Response(Socket socket) throws IOException {
        this.sSocket = socket;
        pwServerOutput = new PrintWriter(socket.getOutputStream(), true);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Methods">
    @Override
    public void run() {
        while (sSocket != null) {
            this.SendToServer(scnrInput.nextLine());
        }
    }

    public void SendToServer(String strMessage) {
        pwServerOutput.println(strMessage);
    }
    
    public void Disconnect() throws IOException{
        this.sSocket.close();
        this.sSocket = null;
    }
    // </editor-fold>
}
